<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>学员管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic }/sdsng/js/join.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			//$("#name").focus();
			
			
			// add by zad 2018-01-30  校验用户名和手机号码是否存在（当用户名和手机号码都存在时，才认为重复）
			/* jQuery.validator.addMethod("mobile", function( value, element ) {
				alert(222);
				return true;
			}, "该用户已存在相同的手机号码，请确认。"); */
			
			
			
			$("#inputForm").validate({
				
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
		});
		
		function selectCourse(iWidth,iHeight)
		{
			// 限定部门查询
			var iTop = (window.screen.availHeight - 20 - iHeight) / 2;
		    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
		    var param = 'height=' + iHeight + ', width=' + iWidth + ', top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no';
		    window.open("${ctx}/ems/emsCourse/select?pageNo=1&pageSize=30", 'course', param);
		    
		}
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ems/emsJoin">学员列表</a></li>
		<li class="active"><a href="${ctx}/ems/emsJoin/form?id=${emsStudent.id}&no=${emsStudent.no}&newType=${newType}"><c:if test="${empty newType || 'add' eq newType}">新</c:if>学员报名<shiro:lacksPermission name="ems:emsStudent:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="emsStudent" action="${ctx}/ems/emsJoin/save" method="post" class="form-horizontal">
		<%-- <form:hidden id="id" path="student.id"/> --%>
		<input type="hidden" name="student.id" id="studentId" readonly="true" value="${emsStudent.id }">
		<input type="hidden" id="newType" name="newType" readonly="true" value="${newType }">
		<sys:message content="${message}"/>	
		<%-- <div class="control-group">
			<label class="control-label">报名人：</label>
			<div class="controls">
				<sys:treeselect id="user" name="user.id" value="${emsStudent.user.id}" labelName="user.name" labelValue="${emsStudent.user.name}"
					title="用户" url="/sys/office/treeData?type=3" cssClass="required" allowClear="true" notAllowSelectParent="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">学员编号：</label>
			<div class="controls">
				<input name="student.no" type="text" htmlEscape="false" value="${emsStudent.no }" readonly maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
				<!-- <span class="help-inline"><font color="red">编号为自动生成，格式：日期+序号组成（yyyymm + 序号）</font> </span> -->
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">学员姓名：</label>
			<div class="controls">
				<input name="student.name" id="studentName" type="text" <c:if test="${newType ne 'add'}">disabled</c:if> value="${emsStudent.name }" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">手机号码：</label>
			<div class="controls">
				<input id="mobile" name="student.mobile" type="text" <c:if test="${newType ne 'add'}">disabled</c:if> value="${emsStudent.mobile }" htmlEscape="false" maxlength="16" class="input-xlarge required"/>
				<label id="tip" class='error' style="display: none;"></label>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">性别：</label>
			<div class="controls">
				<%-- <form:input path="sex" htmlEscape="false" maxlength="2" class="input-xlarge "/> --%>
				<select name="student.sex" <c:if test="${newType ne 'add'}">disabled</c:if> class="input-xlarge required">
					<option value="1" ${emsStudent.sex eq '1'?'selected':''}>男</option>
					<option value="0" ${emsStudent.sex eq '0'?'selected':''}>女</option>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">出生日期：</label>
			<div class="controls">
				<input name="student.birth"  type="text" <c:if test="${newType ne 'add'}">readonly</c:if> maxlength="20" class="input-medium Wdate "
					value='<fmt:formatDate value="${emsStudent.birth}" pattern="yyyy-MM-dd HH:mm:ss"/>'
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">年级：</label>
			<div class="controls">
				<input name="student.grade" type="text" value="${emsStudent.grade }" htmlEscape="false" <c:if test="${newType ne 'add'}">readonly</c:if> maxlength="10" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">学校：</label>
			<div class="controls">
				<input name="student.school" type="text" value="${emsStudent.school }" htmlEscape="false" <c:if test="${newType ne 'add'}">readonly</c:if> maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">地址：</label>
			<div class="controls">
				<input name="student.address" type="text" value="${emsStudent.address }" htmlEscape="false" <c:if test="${newType ne 'add'}">readonly</c:if> maxlength="256" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">往期培训：</label>
			<div class="controls">
				<input name="student.pastTrain" type="text" value="${emsStudent.pastTrain }" htmlEscape="false" <c:if test="${newType ne 'add'}">readonly</c:if> maxlength="256" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否新生：</label>
			<div class="controls">
				<select name="student.isNew" <c:if test="${newType ne 'add'}">disabled</c:if> class="input-xlarge required">
					<option value="" ></option>
					<%-- <options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/> --%>
					<c:forEach items="${fns:getDictList('yes_no')}" var="sex">
						<option value="${sex.value }" ${sex.value eq emsStudent.isNew ? 'selected':''}>${sex.label }</option>
					</c:forEach>
				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">现场折扣：</label>
			<div class="controls">
				<input type="text" id="siteDiscount" name="siteDiscount" htmlEscape="false" value="1" maxlength="256" class="input-xlarge "/>
				<label id="siteDiscountTip" class='error' style="display: none;"></label>
				<span class="help-inline"><font>取值0-1，默认为1；此处折扣不为1时，以此处为准，统一折扣不再计算</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">报名班级：</label>
			<div class="controls">
				<%-- <form:input path="course.id" id="courseId" htmlEscape="false" readonly="true" maxlength="256" class="input-xlarge "/>
				<form:input path="course.name" id="courseName"/> --%>
				<input type="hidden" name="course.id" id="courseId" htmlEscape="false" readonly="true" maxlength="256" class="input-xlarge required"/>
				<input type="text" readonly="true" id="courseName" name="course.name" onchange="doSubmit();" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
				<label id="courseTip" class='error' style="display: none;"></label>
				<input type="button" value="选择报名班级" onclick="selectCourse(1500,800);"/>
			</div>
		</div>
		
		<%-- <div class="control-group">
			<label class="control-label">是否启用：</label>
			<div class="controls">
				<form:select path="status" class="input-xlarge ">
					<form:option value="1" label="是"/>
					<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div> --%>
		<div class="form-actions">
			<shiro:hasPermission name="ems:emsStudent:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" onclick="return doSubmit('addCart');" value="添加到购物车"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>